<template>
    <div>
        <v-header>
            <div slot="left" class="backs_icon"></div>
        </v-header>
        <div class="main_allScroll">
            <group>
                <x-input title="授权码" placeholder="请输入授权码" novalidate :show-clear="false" placeholder-align="right" text-align="right" v-model="authorization" ></x-input>
            </group>
            <button class="btns" :class="disabled" :disabled="disabled != ''"  @click="confirm">下一步</button>
        </div>
    </div>
</template>
<script>
    import { XInput, Group } from 'vux'
    export default {
        components: { XInput, Group },
        data: function () {
            return {
                authorization: '',
                disabled:'disabled'
            }
        },
        activated:function(){
            this.authorization= '';
            this.disabled='disabled';
        },
        methods:{
            confirm(){
                this.queryinfobyidentificationCode()
            },
            queryinfobyidentificationCode(){
                this.$ajax.queryinfobyidentificationCode({identificationCode:this.authorization.trim()})
                    .then((res) => {
                        console.log(Object.prototype.toString.call(res.body.content))
                        if(Object.prototype.toString.call(res.body.content) === '[object Object]'){
                            this.$router.push({path:'/authorization/info',query:{identificationCode:this.authorization.trim()}})
                        }
                    })
            }
        },
        watch:{
            authorization:function () {
                if (this.authorization && this.authorization.trim().length >= 2) {
                    this.disabled = ''
                }else{
                    this.disabled = 'disabled'

                }
            }
        },
    }
</script>
<style lang="less" scoped>
    @import "./css/common.css";
</style>